/* 报警类型枚举 */
enum alarm_type
{
    NO_ALARM,                                                          /* 无报警 */
    UPPER_LIMIT_ABS_ALARM,                                             /* 上限绝对值报警 */
    LOWER_LIMIT_ABS_ALARM,                                             /* 下限绝对值报警 */
    UPPER_LIMIT_ABS_HOLD_ALARM,                                        /* 上限绝对值报警带保持功能 */
    LOWER_LIMIT_ABS_HOLD_ALARM,                                        /* 下限绝对值报警带保持功能 */
    UPPER_LIMIT_DEVIATION_ALARM,                                       /* 上限偏差报警 */
    LOWER_LIMIT_DEVIATION_ALARM,                                       /* 下限偏差报警 */
    UPPER_AND_LOWER_LIMIT_DEVIATION_ALARM,                             /* 上下限偏差报警 */
    UPPER_LIMIT_DEVIATION_HOLD_ALARM,                                  /* 上限偏差报警带保持功能 */
    LOWER_LIMIT_DEVIATION_HOLD_ALARM,                                  /* 下限偏差报警带保持功能 */
    UPPER_AND_LOWER_LIMIT_DEVIATION_HOLD_ALARM,                        /* 上下限偏差报警带保持功能 */
    RANGE_DEVIATION_ALARM,                                             /* 范围偏差报警 */
    OFFLINE_ALARM,                                                     /* 断线报警 */
    DOUBLE_UPPER_AND_LOWER_LIMIT_ABS_ALARM = 16,                       /* 上下限绝对值报警 */
    DOUBLE_UPPER_AND_LOWER_LIMIT_DEVIATION_ALARM,                      /* 上下限偏差报警 */
    DOUBLE_UPPER_LIMIT_ABS_AND_LOWER_LIMIT_DEVIATION_ALARM,            /* 上限绝对值和下限偏差报警 */
    DOUBLE_UPPER_LIMIT_DEVIATION_AND_LOWER_LIMIT_ABS_ALARM,            /* 上限偏差和下限绝对值报警 */
    DOUBLE_UPPER_AND_LOWER_LIMIT_ABS_HOLD_ALARM,                       /* 上下限绝对值报警带保持功能 */
    DOUBLE_UPPER_AND_LOWER_LIMIT_DEVIATION_HOLD_ALARM,                 /* 上下限偏差报警带保持功能 */
    DOUBLE_UPPER_LIMIT_ABS_AND_LOWER_LIMIT_DEVIATION_HOLD_ALARM,       /* 上限绝对值和下限偏差报警带保持功能 */
    DOUBLE_UPPER_LIMIT_DEVIATION_AND_LOWER_LIMIT_ABS_HOLD_ALARM,       /* 上限偏差和下限绝对值报警带保持功能 */
    DOUBLE_RANGE_ABS_ALARM,                                            /* 范围上下限绝对值报警 */
    DOUBLE_RANGE_DEVIATION_ALARM,                                      /* 范围上下限偏差报警 */
    DOUBLE_RANGE_UPPER_LIMIT_ABS_AND_LOWER_LIMIT_DEVIATION_ALARM,      /* 范围上限绝对值和下限偏差报警 */
    DOUBLE_RANGE_UPPER_LIMIT_DEVIATION_AND_LOWER_LIMIT_ABS_ALARM,      /* 范围上限偏差和下限绝对值报警 */
    DOUBLE_RANGE_ABS_HOLD_ALARM,                                       /* 范围上下限绝对值报警带保持功能 */
    DOUBLE_RANGE_DEVIATION_HOLD_ALARM,                                 /* 范围上下限偏差报警带保持功能 */
    DOUBLE_RANGE_UPPER_LIMIT_ABS_AND_LOWER_LIMIT_DEVIATION_HOLD_ALARM, /* 范围上限绝对值和下限偏差报警带保持功能 */
    DOUBLE_RANGE_UPPER_LIMIT_DEVIATION_AND_LOWER_LIMIT_ABS_HOLD_ALARM, /* 范围上限偏差和下限绝对值报警带保持功能 */
};
static int hold_status;
void init_params()
{
    // 初始化参数
    hold_status = 0;
}
/*
 * 上限绝对值报警
 *
 * @param limit 上限
 * @param process_value 被检测的值
 * @return 1: 超过上限, 0: 未超过
 */
int upper_limit_abs_alarm(float limit, float process_value)
{
    if (process_value > limit)
    {
        return 1;
    }
    return 0;
}

/*
 * 下限绝对值报警
 *
 * @param limit 下限
 * @param process_value 被检测的值
 * @return 1: 低于下限, 0: 未低于
 */
int lower_limit_abs_alarm(float limit, float process_value)
{
    if (process_value <= limit)
    {
        return 1;
    }
    return 0;
}
/*
 * 上限绝对值报警带保持功能：所谓保持功能，是指接通电源后，测量值
 * 即使在报警范围内，也不立即使报警打开，待离开报警范围并再次进入
 * 报警范围后，才会发出报警。
 *
 * @param limit 上限
 * @param process_value 被检测的值
 * @return 1: 超过上限, 0: 未超过
 */
int upper_limit_abs_hold_alarm(float limit, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value >= limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value >= limit)
        {
            return 1;
        }
    }
    return 0;
}
/*
 * 下限绝对值报警带保持功能：所谓保持功能，是指接通电源后，测量值
 * 即使在报警范围内，也不立即使报警打开，待离开报警范围并再次进入
 * 报警范围后，才会发出报警。
 *
 * @param limit 下限
 * @param process_value 被检测的值
 * @return 1: 低于下限, 0: 未低于
 */
int lower_limit_abs_hold_alarm(float limit, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value <= limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value <= limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 上限偏差报警
 *
 * @param limit 上限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上限, 0: 未超过
 */
int upper_limit_deviation_alarm(float limit, float setting_value, float process_value)
{
    if (process_value - setting_value >= limit)
    {
        return 1;
    }
    return 0;
}

/* 下限偏差报警
 *
 * @param limit 下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 低于下限, 0: 未低于
 */
int lower_limit_deviation_alarm(float limit, float setting_value, float process_value)
{
    if (setting_value - process_value >= limit)
    {
        return 1;
    }
    return 0;
}

/* 上下偏差报警
 *
 * @param limit 上下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上下限, 0: 未超过
 */
int upper_and_lower_limit_deviation_alarm(float limit, float setting_value, float process_value)
{
    if (process_value - setting_value >= limit || process_value - setting_value <= -limit)
    {
        return 1;
    }
    return 0;
}

/* 上偏差报警带保持
 *
 * @param limit 上限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 */
int upper_limit_deviation_hold_alarm(float limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value - setting_value >= limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value - setting_value >= limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 下偏差报警带保持
 *
 * @param limit 下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 */
int lower_limit_deviation_hold_alarm(float limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (setting_value - process_value >= limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (setting_value - process_value >= limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 上下偏差报警带保持
 *
 * @param limit 上下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 */
int upper_and_lower_limit_deviation_hold_alarm(float limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value - setting_value >= limit || process_value - setting_value <= -limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value - setting_value >= limit || process_value - setting_value <= -limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 范围上下偏差
 *
 * @param limit 上下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上下限, 0: 未超过
 */
int range_deviation_alarm(float limit, float setting_value, float process_value)
{
    if (process_value >= setting_value - limit && process_value <= setting_value + limit)
    {
        return 1;
    }
    return 0;
}

/* 上下限绝对值报警
 *
 * @param upper_limit 上限
 * @param lower_limit 下限
 * @param process_value 被检测的值
 * @return 1: 超过上下限, 0: 未超过
 */
int double_upper_lower_limit_abs_alarm(float upper_limit, float lower_limit, float process_value)
{
    if (process_value >= upper_limit || process_value <= lower_limit)
    {
        return 1;
    }
    return 0;
}

/* 上下限偏差报警
 *
 * @param upper_limit 上限
 * @param lower_limit 下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上下限, 0: 未超过
 */
int double_upper_lower_limit_deviation_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (process_value - setting_value >= upper_limit || process_value - setting_value <= -lower_limit)
    {
        return 1;
    }
    return 0;
}

/* 上限绝对值和下限偏差报警
 *
 * @param upper_limit 上限
 * @param lower_limit 下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上限或低于下限, 0: 未超过
 */
int double_upper_limit_abs_and_lower_limit_deviation_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (process_value >= upper_limit || process_value - setting_value <= -lower_limit)
    {
        return 1;
    }
    return 0;
}

/* 上限偏差和下限绝对值报警
 *
 * @param upper_limit 上限
 * @param lower_limit 下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上限或低于下限, 0: 未超过
 */
int double_upper_limit_deviation_and_lower_limit_abs_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (process_value - setting_value >= upper_limit || process_value <= lower_limit)
    {
        return 1;
    }
    return 0;
}

/* 带保持的上下限绝对值报警
 *
 * @param upper_limit 上限
 * @param lower_limit 下限
 * @param process_value 被检测的值
 * @return 1: 超过上下限, 0: 未超过
 */
int double_upper_lower_limit_abs_hold_alarm(float upper_limit, float lower_limit, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value >= upper_limit || process_value <= lower_limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value >= upper_limit || process_value <= lower_limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 带保持的上下限偏差报警
 *
 * @param upper_limit 上限
 * @param lower_limit 下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上下限, 0: 未超过
 */
int double_upper_lower_limit_deviation_hold_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value - setting_value >= upper_limit || process_value - setting_value <= -lower_limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value - setting_value >= upper_limit || process_value - setting_value <= -lower_limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 带保持的上限绝对值和下限偏差报警
 *
 * @param upper_limit 上限
 * @param lower_limit 下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上限或低于下限, 0: 未超过
 */
int double_upper_limit_abs_and_lower_limit_deviation_hold_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value >= upper_limit || process_value - setting_value <= -lower_limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value >= upper_limit || process_value - setting_value <= -lower_limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 带保持的上限偏差和下限绝对值报警
 *
 * @param upper_limit 上限
 * @param lower_limit 下限
 * @param setting_value 设置值
 * @param process_value 被检测的值
 * @return 1: 超过上限或低于下限, 0: 未超过
 */
int double_upper_limit_deviation_and_lower_limit_abs_hold_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value - setting_value >= upper_limit || process_value <= lower_limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value - setting_value >= upper_limit || process_value <= lower_limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 范围上下限绝对值报警 */
int double_range_abs_alarm(float upper_limit, float lower_limit, float process_value)
{
    if (process_value <= upper_limit && process_value >= lower_limit)
    {
        return 1;
    }
    return 0;
}

/* 范围上下限偏差报警 */
int double_range_deviation_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (process_value - setting_value <= upper_limit && process_value - setting_value >= -lower_limit)
    {
        return 1;
    }
    return 0;
}

/* 范围上限绝对值和下限偏差报警 */
int double_range_upper_limit_abs_and_lower_limit_deviation_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (process_value - setting_value >= -lower_limit && process_value <= upper_limit)
    {
        return 1;
    }
    return 0;
}

/* 范围上限偏差和下限绝对值报警 */
int double_range_upper_limit_deviation_and_lower_limit_abs_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (process_value - setting_value <= upper_limit && process_value >= lower_limit)
    {
        return 1;
    }
    return 0;
}

/* 带保持的范围上下限绝对值报警 */
int double_range_abs_hold_alarm(float upper_limit, float lower_limit, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value <= upper_limit && process_value >= lower_limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value <= upper_limit && process_value >= lower_limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 带保持的范围上下限偏差报警 */
int double_range_deviation_hold_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value - setting_value <= upper_limit && process_value - setting_value >= -lower_limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value - setting_value <= upper_limit && process_value - setting_value >= -lower_limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 带保持的上限绝对值和下限偏差报警 */
int double_range_upper_limit_abs_and_lower_limit_deviation_hold_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value - setting_value >= -lower_limit && process_value <= upper_limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value - setting_value >= -lower_limit && process_value <= upper_limit)
        {
            return 1;
        }
    }
    return 0;
}

/* 带保持的范围上限偏差和下限绝对值报警 */
int double_range_upper_limit_deviation_and_lower_limit_abs_hold_alarm(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    if (hold_status == 0)
    {
        if (process_value - setting_value <= upper_limit && process_value >= lower_limit)
        {
            hold_status = 1;
            return 0; // 第一次不报警
        }
    }
    if (hold_status == 1)
    {
        if (process_value - setting_value <= upper_limit && process_value >= lower_limit)
        {
            return 1;
        }
    }
    return 0;
}
void upper_limit_abs_alarm_handler(float upper_limit, float process_value)
{
    printf("请输入报警上限：");
    scanf("%f", &upper_limit);
    printf("请输入被检测的值：");
    scanf("%f", &process_value);
    if (upper_limit_abs_alarm(upper_limit, process_value))
    {
        printf("超过上限\n");
    }
}
void lower_limit_abs_alarm_handler(float lower_limit, float process_value)
{
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (lower_limit_abs_alarm(lower_limit, process_value))
    {
        printf("低于下限\n");
    }
}
void upper_limit_abs_hold_alarm_handler(float upper_limit, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }

    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (upper_limit_abs_hold_alarm(upper_limit, process_value))
    {
        printf("超过上限\n");
    }
}
void lower_limit_abs_hold_alarm_handler(float lower_limit, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (lower_limit_abs_hold_alarm(lower_limit, process_value))
    {
        printf("低于下限\n");
    }
}
void upper_limit_deviation_alarm_handler(float upper_limit, float setting_value, float process_value)
{
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (upper_limit_deviation_alarm(upper_limit, setting_value, process_value))
    {
        printf("超过上限偏差\n");
    }
}
void lower_limit_deviation_alarm_handler(float lower_limit, float setting_value, float process_value)
{
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (lower_limit_deviation_alarm(lower_limit, setting_value, process_value))
    {
        printf("低于下限偏差\n");
    }
}
void upper_and_lower_limit_deviation_alarm_handler(float upper_and_lower_limit, float setting_value, float process_value)
{
    printf("请输入报警上下限偏差: ");
    scanf("%f", &upper_and_lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (upper_and_lower_limit_deviation_alarm(upper_and_lower_limit, setting_value, process_value))
    {
        printf("超过上下限偏差\n");
    }
}
void upper_limit_deviation_hold_alarm_handler(float upper_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (upper_limit_deviation_hold_alarm(upper_limit, setting_value, process_value))
    {
        printf("超过上限偏差\n");
    }
}
void lower_limit_deviation_hold_alarm_handler(float lower_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (lower_limit_deviation_hold_alarm(lower_limit, setting_value, process_value))
    {
        printf("低于下限偏差\n");
    }
}
void upper_and_lower_limit_deviation_hold_alarm_handler(float upper_and_lower_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上下限偏差: ");
    scanf("%f", &upper_and_lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (upper_and_lower_limit_deviation_hold_alarm(upper_and_lower_limit, setting_value, process_value))
    {
        printf("超过上下限偏差\n");
    }
}
void range_deviation_alarm_handler(float range_deviation, float setting_value, float process_value)
{
    printf("请输入报警范围偏差: ");
    scanf("%f", &range_deviation);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (range_deviation_alarm(range_deviation, setting_value, process_value))
    {
        printf("超过范围偏差\n");
    }
}
void offline_alarm_handler(void)
{
    printf("断线报警\n");
}
void double_upper_lower_limit_abs_alarm_handler(float upper_limit, float lower_limit, float process_value)
{
    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_upper_lower_limit_abs_alarm(upper_limit, lower_limit, process_value))
    {
        printf("超过上限或低于下限\n");
    }
}
void double_upper_lower_limit_deviation_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_upper_lower_limit_deviation_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("超过上限或低于下限\n");
    }
}
void double_upper_limit_abs_and_lower_limit_deviation_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_upper_limit_abs_and_lower_limit_deviation_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("超过上限或低于下限\n");
    }
}
void double_upper_limit_deviation_and_lower_limit_abs_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_upper_limit_deviation_and_lower_limit_abs_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("超过上限或低于下限\n");
    }
}
void double_upper_lower_limit_abs_hold_alarm_handler(float upper_limit, float lower_limit, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_upper_lower_limit_abs_hold_alarm(upper_limit, lower_limit, process_value))
    {
        printf("超过上限或低于下限\n");
    }
}
void double_upper_lower_limit_deviation_hold_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_upper_lower_limit_deviation_hold_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("超过上限或低于下限\n");
    }
}
void double_upper_limit_abs_and_lower_limit_deviation_hold_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_upper_limit_abs_and_lower_limit_deviation_hold_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("超过上限或低于下限\n");
    }
}
void double_upper_limit_deviation_and_lower_limit_abs_hold_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_upper_limit_deviation_and_lower_limit_abs_hold_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("超过上限或低于下限\n");
    }
}
void double_range_abs_alarm_handler(float upper_limit, float lower_limit, float process_value)
{
    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_range_abs_alarm(upper_limit, lower_limit, process_value))
    {
        printf("处于上下限报警范围\n");
    }
}
void double_range_deviation_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_range_deviation_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("处于上下限报警范围\n");
    }
}
void double_range_upper_limit_abs_and_lower_limit_deviation_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_range_upper_limit_abs_and_lower_limit_deviation_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("处于报警范围\n");
    }
}
void double_range_upper_limit_deviation_and_lower_limit_abs_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_range_upper_limit_deviation_and_lower_limit_abs_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("处于报警范围\n");
    }
}
void double_range_abs_hold_alarm_handler(float upper_limit, float lower_limit, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_range_abs_hold_alarm(upper_limit, lower_limit, process_value))
    {
        printf("处于报警范围\n");
    }
}
void double_range_deviation_hold_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_range_deviation_hold_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("处于报警范围\n");
    }
}
void double_range_upper_limit_abs_and_lower_limit_deviation_hold_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限偏差: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_range_upper_limit_abs_and_lower_limit_deviation_hold_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("处于报警范围\n");
    }
}
void double_range_upper_limit_deviation_and_lower_limit_abs_hold_alarm_handler(float upper_limit, float lower_limit, float setting_value, float process_value)
{
    static int has_initialized = 0; // 静态变量，只初始化一次
    if (!has_initialized)
    {
        init_params(); // 初始化参数
        has_initialized = 1;
    }
    printf("请输入报警上限偏差: ");
    scanf("%f", &upper_limit);
    printf("请输入报警下限: ");
    scanf("%f", &lower_limit);
    printf("请输入设置值: ");
    scanf("%f", &setting_value);
    printf("请输入被检测的值: ");
    scanf("%f", &process_value);
    if (double_range_upper_limit_deviation_and_lower_limit_abs_hold_alarm(upper_limit, lower_limit, setting_value, process_value))
    {
        printf("处于报警范围\n");
    }
}
